import React, { useState, useEffect } from 'react'
import { View, Image } from '@tarojs/components'
import { AtTabs, AtTabsPane } from 'taro-ui'
import './index.less'
import "taro-ui/dist/style/components/tabs.scss";
import api from '../http/api'
export default (props: any) => {
    const [current, setCurrent] = useState(0)
    const [tabList, setTabList] = useState([])
    useEffect(() => {
       getData()
    }, [])
    //获取列表数据
    const getData = async () => {
        const data = {
            uSchoolId: props.schoolId,
        }
        const res: any = await api.scAticleType(data)
        const newArr =res.data.map((item:any)=>{
            return {
                title:item.name
            }
        })
        setTabList(newArr)
    }
    const handleClick = (value: any) => {
        setCurrent(value)
        props.data(value+1)
    }
    return (
        <View className='tabBox'>
            <AtTabs scroll current={current} tabList={tabList} onClick={handleClick}>
            </AtTabs>
        </View>

    );
};
